package com.itheima.dubbo.api;

import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.itheima.dubbo.mapper.UserInfoMapper;
import com.itheima.dubbo.mapper.UserMapper;
import com.tanhua.domain.db.UserInfo;
import com.tanhua.dubbo.api.UserInfoApi;
import org.apache.dubbo.config.annotation.Service;
import org.springframework.beans.factory.annotation.Autowired;

@Service
public class UserInfoImpl implements UserInfoApi {

    @Autowired
    private UserMapper userMapper;
    @Autowired
    private UserInfoMapper userInfoMapper;

    @Override
    public void save(UserInfo userInfo) {
       //userInfo.setCreated(new Date());
      // userInfo.setUpdated(new Date());
       userInfoMapper.insert(userInfo);
    }

    @Override
    public void update(UserInfo userInfo) {
      //  userInfo.setUpdated(new Date());
        userInfoMapper.updateById(userInfo);

    }

    @Override
    public UserInfo findById(Long userId) {

        return  userInfoMapper.selectById(userId);
    }

    //用户管理-分页用户分页列表
    @Override
    public IPage<UserInfo> findUserList(int page, int pagesize) {

        return userInfoMapper.selectPage(new Page<>(page,pagesize),null);
    }
}
